#!/bin/sh
#######################################################################
# Begin samba
#
# Description : Start samba server
#
# Author      : Bruce Dubbs - bdubbs@linuxfromscratch.org
#
# Version     : BLFS 7.0
#
########################################################################


### BEGIN INIT INFO
# Provides:            samba
# Required-Start:      $network
# Should-Start:        networkmanager slapd ntpd wicd
# Required-Stop:       $network
# Should-Stop:         networkmanager slapd ntpd wicd
# Default-Start:       3 4 5
# Default-Stop:        0 1 2 6
# Short-Description:   Provides SMB (Windows) networking.
# Description:         Starts Samba smbd and nmbd processess which provide
#                      connectivity to SMB (Windows) networks.
# X-LFS-Provided-By:   BLFS
### END INIT INFO

. /lib/lsb/init-functions

#$LastChangedBy: dj $
#$Date: 2019-09-08 13:50:13 -0500 (Sun, 08 Sep 2019) $

case "$1" in
   start)
      mkdir -p /run/samba

      log_info_msg "Starting nmbd..."
      start_daemon /usr/sbin/nmbd -D
      evaluate_retval

      log_info_msg "Starting smbd..."
      start_daemon /usr/sbin/smbd -D
      evaluate_retval
      ;;

   stop)
      log_info_msg "Stopping smbd..."
      killproc /usr/sbin/smbd
      evaluate_retval

      log_info_msg "Stopping nmbd..."
      killproc /usr/sbin/nmbd
      evaluate_retval
      ;;

   reload)
      log_info_msg "Reloading smbd..."
      killproc /usr/sbin/smbd -HUP
      evaluate_retval

      log_info_msg "Reloading nmbd..."
      killproc /usr/sbin/nmbd -HUP
      evaluate_retval
      ;;

   restart)
      $0 stop
      sleep 1
      $0 start
      ;;

   status)
      statusproc /usr/sbin/nmbd
      statusproc /usr/sbin/smbd
      ;;

   *)
      echo "Usage: $0 {start|stop|reload|restart|status}"
      exit 1
      ;;
esac

# End /etc/init.d/samba
